package com.sh.controller;

import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sh.util.MqttUtils;
import com.sh.util.PropertiesUtils;

/**
 * @comments
 * @author zg
 * @date 2018年4月5日
 */
@Controller
@RequestMapping("/test")
public class TestController {
	private static Logger logger = LogManager.getLogger(TestController.class);
	
	@Autowired
    private MqttUtils mqttUtils;

	@RequestMapping("/hello")
	public String hello(Map<String, Object> map) {
		logger.info("TestController>>>>>>>>>>>>>>>>>>>>>");
		map.put("name", "[Angel]");
		
		logger.info("mqtt username:{},clientId={}", mqttUtils.getUserName(), mqttUtils.getClientId());
		PropertiesUtils pro = new PropertiesUtils("/conf.properties");
		logger.info("bind.checkFrequencyMsec={}",pro.getString("bind.checkFrequencyMsec"));
		return "test";
	}
	
	@ResponseBody
	@RequestMapping("/hell-go")
	public Object helloGo(String reqContent) {
		logger.info("reqContent:{}", reqContent);
		return "hello go!";
	}

}
